﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.Web;
namespace JumbotCms.Extends.Placard
{
    public partial class _index : JumbotCms.API.FrontHtml
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckExtendState("Placard");
            string ContentStr = LoadPlugin_Placard(Str2Str(q("id")));
            Response.Write(ContentStr);//直接输出
        }
        /// <summary>
        /// 生成公告页
        /// </summary>
        /// <returns></returns>
        private string LoadPlugin_Placard(string id)
        {
            string PageStr = string.Empty;
            PageStr = Jumbot.Common.DirFile.ReadFile(site.Dir + "extends/placard/templates/index.htm");
            ReplaceSiteTags(ref PageStr);
            doh.Reset();
            doh.SqlCmd = "SELECT [Id],[Title],[Content],[AddTime] FROM [jcms_extends_placard] WHERE [Id]=" + id;
            DataTable dtPlacard = doh.GetDataTable();
            if (dtPlacard.Rows.Count > 0)
            {
                for (int i = 0; i < dtPlacard.Columns.Count; i++)
                {
                    PageStr = PageStr.Replace("{$Placard" + dtPlacard.Columns[i].ColumnName + "}", dtPlacard.Rows[0][i].ToString());
                }
                PageStr = PageStr.Replace("{$PlacardAddDate}", Convert.ToDateTime(dtPlacard.Rows[0]["AddTime"].ToString()).ToShortDateString());

            }
            else
                return "参数错误,没有您想查找的公告内容";
            dtPlacard.Clear();
            dtPlacard.Dispose();
            return PageStr;

        }
    }
}
